<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   一次非常有意思的sql优化经历（完整补充版）  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/16381.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466459638: Accept with keywords: (title(0.166666666667):有意思,经历,社区,数盟,版,优化, topn(0.366666666667):社区,数盟,行业资讯,时间,条件,数据挖掘,数据分析,前缀,结果,人工智能,职业规划,效率,计划,基础架构,文章,情况,可视化,排序,数据,场景,磁盘,优化,区分度,语句,极大,编程语言,耗时,字段,数据量,行业).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    一次非常有意思的sql优化经历（完整补充版）
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    一次非常有意思的sql优化经历（完整补充版） | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,69] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/base">
       基础架构
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/16381.html">
          一次非常有意思的sql优化经历（完整补充版）
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          2,315 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/base" rel="category tag">
          基础架构
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <div id="cnblogs_post_body">
        <h3>
         场景
        </h3>
        <p>
         我用的数据库是mysql5.6，下面简单的介绍下场景
        </p>
        <p>
         课程表
        </p>
        <div class="cnblogs_code">
         <div class="cnblogs_code_toolbar">
         </div>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10a88921629605" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            create table Course(

c_id int PRIMARY KEY,

name varchar(10)

)
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10a88921629605-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10a88921629605-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10a88921629605-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10a88921629605-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10a88921629605-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10a88921629605-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10a88921629605-7">
                 7
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10a88921629605-1">
                 <span class="crayon-e">
                  create
                 </span>
                 <span class="crayon-e">
                  table
                 </span>
                 <span class="crayon-e">
                  Course
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10a88921629605-2">
                </div>
                <div class="crayon-line" id="crayon-576865dd10a88921629605-3">
                 <span class="crayon-e">
                  c_id
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  PRIMARY
                 </span>
                 <span class="crayon-v">
                  KEY
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10a88921629605-4">
                </div>
                <div class="crayon-line" id="crayon-576865dd10a88921629605-5">
                 <span class="crayon-e">
                  name
                 </span>
                 <span class="crayon-e">
                  varchar
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-cn">
                  10
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10a88921629605-6">
                </div>
                <div class="crayon-line" id="crayon-576865dd10a88921629605-7">
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0010 seconds] -->
         <p>
         </p>
         <div class="cnblogs_code_toolbar">
         </div>
        </div>
        <p>
         数据100条
        </p>
        <p>
         学生表:
        </p>
        <div class="cnblogs_code">
         <div class="cnblogs_code_toolbar">
         </div>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10aac895893871" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            create table Student(

id int PRIMARY KEY,

name varchar(10)

)
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10aac895893871-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10aac895893871-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10aac895893871-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10aac895893871-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10aac895893871-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10aac895893871-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10aac895893871-7">
                 7
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10aac895893871-1">
                 <span class="crayon-e">
                  create
                 </span>
                 <span class="crayon-e">
                  table
                 </span>
                 <span class="crayon-e">
                  Student
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10aac895893871-2">
                </div>
                <div class="crayon-line" id="crayon-576865dd10aac895893871-3">
                 <span class="crayon-e">
                  id
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  PRIMARY
                 </span>
                 <span class="crayon-v">
                  KEY
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10aac895893871-4">
                </div>
                <div class="crayon-line" id="crayon-576865dd10aac895893871-5">
                 <span class="crayon-e">
                  name
                 </span>
                 <span class="crayon-e">
                  varchar
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-cn">
                  10
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10aac895893871-6">
                </div>
                <div class="crayon-line" id="crayon-576865dd10aac895893871-7">
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0011 seconds] -->
         <p>
         </p>
         <div class="cnblogs_code_toolbar">
         </div>
        </div>
        <p>
         数据70000条
        </p>
        <p>
         学生成绩表SC
        </p>
        <div class="cnblogs_code">
         <div class="cnblogs_code_toolbar">
         </div>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10ab4761303682" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            CREATE table SC(

    sc_id int PRIMARY KEY,

    s_id int,

    c_id int,

    score int

)
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10ab4761303682-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ab4761303682-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ab4761303682-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ab4761303682-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ab4761303682-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ab4761303682-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ab4761303682-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ab4761303682-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ab4761303682-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ab4761303682-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ab4761303682-11">
                 11
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10ab4761303682-1">
                 <span class="crayon-e">
                  CREATE
                 </span>
                 <span class="crayon-e">
                  table
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ab4761303682-2">
                </div>
                <div class="crayon-line" id="crayon-576865dd10ab4761303682-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  sc_id
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  PRIMARY
                 </span>
                 <span class="crayon-v">
                  KEY
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ab4761303682-4">
                </div>
                <div class="crayon-line" id="crayon-576865dd10ab4761303682-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  s_id
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ab4761303682-6">
                </div>
                <div class="crayon-line" id="crayon-576865dd10ab4761303682-7">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  c_id
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ab4761303682-8">
                </div>
                <div class="crayon-line" id="crayon-576865dd10ab4761303682-9">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  score
                 </span>
                 <span class="crayon-t">
                  int
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ab4761303682-10">
                </div>
                <div class="crayon-line" id="crayon-576865dd10ab4761303682-11">
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0013 seconds] -->
         <p>
         </p>
         <div class="cnblogs_code_toolbar">
         </div>
        </div>
        <p>
         数据70w条
        </p>
        <p>
         查询目的：
        </p>
        <p>
         查找语文考100分的考生
        </p>
        <p>
         查询语句：
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10aba329383291" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            select s.* from Student s where s.s_id in (select s_id from SC sc where sc.c_id = 0 and sc.score = 100 )
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10aba329383291-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10aba329383291-1">
                 <span class="crayon-i">
                  select
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-o">
                  *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-i">
                  Student
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  s
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  where
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  s_id
                 </span>
                 <span class="crayon-st">
                  in
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-e">
                  select
                 </span>
                 <span class="crayon-e">
                  s_id
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-e">
                  sc
                 </span>
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  100
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0078 seconds] -->
        </div>
        <p>
         执行时间：30248.271s
        </p>
        <p>
         晕,为什么这么慢，先来查看下查询计划：
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10ac0993196499" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            EXPLAIN 

select s.* from Student s where s.s_id in (select s_id from SC sc where sc.c_id = 0 and sc.score = 100 )
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10ac0993196499-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ac0993196499-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ac0993196499-3">
                 3
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10ac0993196499-1">
                 <span class="crayon-e">
                  EXPLAIN
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ac0993196499-2">
                </div>
                <div class="crayon-line" id="crayon-576865dd10ac0993196499-3">
                 <span class="crayon-i">
                  select
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-o">
                  *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-i">
                  Student
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  s
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  where
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  s_id
                 </span>
                 <span class="crayon-st">
                  in
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-e">
                  select
                 </span>
                 <span class="crayon-e">
                  s_id
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-e">
                  sc
                 </span>
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  100
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0074 seconds] -->
        </div>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281308508332906.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281308547249718.png"/>
         </a>
        </p>
        <p>
         发现没有用到索引，type全是ALL，那么首先想到的就是建立一个索引，建立索引的字段当然是在where条件的字段。
        </p>
        <p>
         先给sc表的c_id和score建个索引
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10ac6822432180" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            CREATE index sc_c_id_index on SC(c_id);
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10ac6822432180-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10ac6822432180-1">
                 <span class="crayon-e">
                  CREATE
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-e">
                  sc_c_id_index
                 </span>
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0077 seconds] -->
         <br/>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10acc420191292" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            CREATE index sc_score_index on SC(score);
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10acc420191292-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10acc420191292-1">
                 <span class="crayon-e">
                  CREATE
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-e">
                  sc_score_index
                 </span>
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0007 seconds] -->
        </div>
        <p>
         再次执行上述查询语句，时间为: 1.054s
        </p>
        <p>
         快了3w多倍，大大缩短了查询时间，看来索引能极大程度的提高查询效率，建索引很有必要，很多时候都忘记建
        </p>
        <p>
         索引了，数据量小的的时候压根没感觉，这优化的感觉挺爽。
        </p>
        <p>
         但是1s的时间还是太长了，还能进行优化吗，仔细看执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281308568337873.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281308586306058.png"/>
         </a>
        </p>
        <p>
         查看优化后的sql:
        </p>
        <div class="cnblogs_code">
         <div class="cnblogs_code_toolbar">
         </div>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10ad3403038360" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            SELECT
    `YSB`.`s`.`s_id` AS `s_id`,
    `YSB`.`s`.`name` AS `name`
FROM
    `YSB`.`Student` `s`
WHERE
    &amp;lt; in_optimizer &amp;gt; (
        `YSB`.`s`.`s_id` ,&amp;lt; EXISTS &amp;gt; (
            SELECT
                1
            FROM
                `YSB`.`SC` `sc`
            WHERE
                (
                    (`YSB`.`sc`.`c_id` = 0)
                    AND (`YSB`.`sc`.`score` = 100)
                    AND (
                        &amp;lt; CACHE &amp;gt; (`YSB`.`s`.`s_id`) = `YSB`.`sc`.`s_id`
                    )
                )
        )
    )
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-13">
                 13
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-14">
                 14
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-15">
                 15
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-16">
                 16
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-17">
                 17
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-18">
                 18
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-19">
                 19
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-20">
                 20
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ad3403038360-21">
                 21
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ad3403038360-22">
                 22
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-1">
                 <span class="crayon-i">
                  SELECT
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  AS
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  name
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  AS
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  name
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-4">
                 <span class="crayon-i">
                  FROM
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  Student
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-6">
                 <span class="crayon-v">
                  WHERE
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-7">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  in_optimizer
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-8">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  EXISTS
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-9">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  SELECT
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-10">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  1
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-11">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  FROM
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-12">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  SC
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-13">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  WHERE
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-14">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-15">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-16">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  AND
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  100
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-17">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  AND
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-18">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  lt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  CACHE
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  &amp;
                 </span>
                 <span class="crayon-v">
                  gt
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-19">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-20">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10ad3403038360-21">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ad3403038360-22">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0230 seconds] -->
         <p>
         </p>
         <div class="cnblogs_code_toolbar">
         </div>
        </div>
        <p>
         补充：这里有网友问怎么查看优化后的语句
        </p>
        <p>
         方法如下：
        </p>
        <p>
         在命令窗口执行
         <a href="http://images.cnitblog.com/blog/722277/201504/281342048962810.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281342054113251.png"/>
         </a>
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281342059581151.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281342066157550.png"/>
         </a>
        </p>
        <p>
         有type=all
        </p>
        <p>
         按照我之前的想法，该sql的执行的顺序应该是先执行子查询
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10ada822563118" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            select s_id from SC sc where sc.c_id = 0 and sc.score = 100
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10ada822563118-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10ada822563118-1">
                 <span class="crayon-e">
                  select
                 </span>
                 <span class="crayon-e">
                  s_id
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-e">
                  sc
                 </span>
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  100
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0067 seconds] -->
        </div>
        <p>
         耗时：0.001s
        </p>
        <p>
         得到如下结果：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281308597865371.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281309007557442.png"/>
         </a>
        </p>
        <p>
         然后再执行
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10ae0430363437" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            select s.* from Student s where s.s_id in(7,29,5000)
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10ae0430363437-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10ae0430363437-1">
                 <span class="crayon-i">
                  select
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-o">
                  *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-i">
                  Student
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  s
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  where
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  s_id
                 </span>
                 <span class="crayon-st">
                  in
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-cn">
                  7
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-cn">
                  29
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-cn">
                  5000
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0069 seconds] -->
        </div>
        <p>
         耗时：0.001s
        </p>
        <p>
         这样就是相当快了啊，Mysql竟然不是先执行里层的查询，而是将sql优化成了exists子句，并出现了EPENDENT SUBQUERY，
        </p>
        <p>
         mysql是先执行外层查询，再执行里层的查询，这样就要循环70007*11=770077次。
        </p>
        <p>
         那么改用连接查询呢？
        </p>
        <div class="cnblogs_code">
         <div class="cnblogs_code_toolbar">
         </div>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10ae6717222461" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            SELECT s.* from 

Student s

INNER JOIN SC sc

on sc.s_id = s.s_id

where sc.c_id=0 and sc.score=100
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10ae6717222461-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ae6717222461-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ae6717222461-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ae6717222461-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ae6717222461-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ae6717222461-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ae6717222461-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10ae6717222461-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10ae6717222461-9">
                 9
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10ae6717222461-1">
                 <span class="crayon-i">
                  SELECT
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-o">
                  *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ae6717222461-2">
                </div>
                <div class="crayon-line" id="crayon-576865dd10ae6717222461-3">
                 <span class="crayon-i">
                  Student
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  s
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ae6717222461-4">
                </div>
                <div class="crayon-line" id="crayon-576865dd10ae6717222461-5">
                 <span class="crayon-e">
                  INNER
                 </span>
                 <span class="crayon-e">
                  JOIN
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-e">
                  sc
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ae6717222461-6">
                </div>
                <div class="crayon-line" id="crayon-576865dd10ae6717222461-7">
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  s_id
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10ae6717222461-8">
                </div>
                <div class="crayon-line" id="crayon-576865dd10ae6717222461-9">
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-cn">
                  100
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0077 seconds] -->
         <p>
         </p>
         <div class="cnblogs_code_toolbar">
         </div>
        </div>
        <p>
         这里为了重新分析连接查询的情况，先暂时删除索引sc_c_id_index，sc_score_index
        </p>
        <p>
         执行时间是：0.057s
        </p>
        <p>
         效率有所提高，看看执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281309019116755.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281309029749797.png"/>
         </a>
        </p>
        <p>
         这里有连表的情况出现，我猜想是不是要给sc表的s_id建立个索引
        </p>
        <p>
         CREATE index sc_s_id_index on SC(s_id);
        </p>
        <p>
         show index from SC
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281309039744626.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281309058965539.png"/>
         </a>
        </p>
        <p>
         在执行连接查询
        </p>
        <p>
         时间: 1.076s，竟然时间还变长了，什么原因？查看执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281309076938021.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281309104742507.png"/>
         </a>
        </p>
        <p>
         优化后的查询语句为：
        </p>
        <div class="cnblogs_code">
         <div class="cnblogs_code_toolbar">
         </div>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10aed333778385" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            SELECT
    `YSB`.`s`.`s_id` AS `s_id`,
    `YSB`.`s`.`name` AS `name`
FROM
    `YSB`.`Student` `s`
JOIN `YSB`.`SC` `sc`
WHERE
    (
        (
            `YSB`.`sc`.`s_id` = `YSB`.`s`.`s_id`
        )
        AND (`YSB`.`sc`.`score` = 100)
        AND (`YSB`.`sc`.`c_id` = 0)
    )
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10aed333778385-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10aed333778385-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10aed333778385-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10aed333778385-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10aed333778385-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10aed333778385-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10aed333778385-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10aed333778385-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10aed333778385-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10aed333778385-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10aed333778385-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10aed333778385-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10aed333778385-13">
                 13
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10aed333778385-14">
                 14
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10aed333778385-1">
                 <span class="crayon-i">
                  SELECT
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10aed333778385-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  AS
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10aed333778385-3">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  name
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  AS
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  name
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10aed333778385-4">
                 <span class="crayon-i">
                  FROM
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10aed333778385-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  Student
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10aed333778385-6">
                 <span class="crayon-i">
                  JOIN
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  SC
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10aed333778385-7">
                 <span class="crayon-e">
                  WHERE
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10aed333778385-8">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10aed333778385-9">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10aed333778385-10">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10aed333778385-11">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10aed333778385-12">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  AND
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  100
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10aed333778385-13">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  AND
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  YSB
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-sy">
                  `
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10aed333778385-14">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0130 seconds] -->
         <p>
         </p>
         <div class="cnblogs_code_toolbar">
         </div>
        </div>
        <p>
         貌似是先做的连接查询，再进行的where条件过滤
        </p>
        <p>
         回到前面的执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281309121615490.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281309140361418.png"/>
         </a>
        </p>
        <p>
         这里是先做的where条件过滤，再做连表，执行计划还不是固定的，那么我们先看下标准的sql执行顺序：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281309162242017.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281309183339171.png"/>
         </a>
        </p>
        <p>
         正常情况下是先join再进行where过滤，但是我们这里的情况，如果先join，将会有70w条数据发送join做操，因此先执行where
        </p>
        <p>
         过滤是明智方案，现在为了排除mysql的查询优化，我自己写一条优化后的sql
        </p>
        <div class="cnblogs_code">
         <div class="cnblogs_code_toolbar">
         </div>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10af4057972243" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            SELECT
    s.*
FROM
    (
        SELECT
            *
        FROM
            SC sc
        WHERE
            sc.c_id = 0
        AND sc.score = 100
    ) t
INNER JOIN Student s ON t.s_id = s.s_id
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10af4057972243-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10af4057972243-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10af4057972243-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10af4057972243-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10af4057972243-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10af4057972243-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10af4057972243-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10af4057972243-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10af4057972243-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10af4057972243-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10af4057972243-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10af4057972243-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10af4057972243-13">
                 13
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10af4057972243-1">
                 <span class="crayon-i">
                  SELECT
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10af4057972243-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-o">
                  *
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10af4057972243-3">
                 <span class="crayon-e">
                  FROM
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10af4057972243-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10af4057972243-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e ">
                  SELECT
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10af4057972243-6">
                 <span class="crayon-e ">
                  *
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10af4057972243-7">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  FROM
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10af4057972243-8">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-e">
                  sc
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10af4057972243-9">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-e">
                  WHERE
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10af4057972243-10">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10af4057972243-11">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  AND
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  100
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10af4057972243-12">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  t
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10af4057972243-13">
                 <span class="crayon-e">
                  INNER
                 </span>
                 <span class="crayon-e">
                  JOIN
                 </span>
                 <span class="crayon-i">
                  Student
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  s
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  ON
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  t
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0022 seconds] -->
         <p>
         </p>
         <div class="cnblogs_code_toolbar">
         </div>
        </div>
        <p>
         即先执行sc表的过滤，再进行表连接，执行时间为：0.054s
        </p>
        <p>
         和之前没有建s_id索引的时间差不多
        </p>
        <p>
         查看执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281309201619112.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281309215684883.png"/>
         </a>
        </p>
        <p>
         先提取sc再连表，这样效率就高多了，现在的问题是提取sc的时候出现了扫描表，那么现在可以明确需要建立相关索引
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10afb336725506" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            CREATE index sc_c_id_index on SC(c_id);
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10afb336725506-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10afb336725506-1">
                 <span class="crayon-e">
                  CREATE
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-e">
                  sc_c_id_index
                 </span>
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0006 seconds] -->
         <br/>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b00855610886" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            CREATE index sc_score_index on SC(score);
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b00855610886-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b00855610886-1">
                 <span class="crayon-e">
                  CREATE
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-e">
                  sc_score_index
                 </span>
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0006 seconds] -->
        </div>
        <p>
         再执行查询：
        </p>
        <div class="cnblogs_code">
         <div class="cnblogs_code_toolbar">
         </div>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b06412507448" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            SELECT
    s.*
FROM
    (
        SELECT
            *
        FROM
            SC sc
        WHERE
            sc.c_id = 0
        AND sc.score = 100
    ) t
INNER JOIN Student s ON t.s_id = s.s_id
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b06412507448-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b06412507448-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b06412507448-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b06412507448-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b06412507448-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b06412507448-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b06412507448-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b06412507448-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b06412507448-9">
                 9
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b06412507448-10">
                 10
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b06412507448-11">
                 11
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b06412507448-12">
                 12
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b06412507448-13">
                 13
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b06412507448-1">
                 <span class="crayon-i">
                  SELECT
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b06412507448-2">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-o">
                  *
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10b06412507448-3">
                 <span class="crayon-e">
                  FROM
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b06412507448-4">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10b06412507448-5">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e ">
                  SELECT
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b06412507448-6">
                 <span class="crayon-e ">
                  *
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10b06412507448-7">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  FROM
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b06412507448-8">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-e">
                  sc
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10b06412507448-9">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-e">
                  WHERE
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b06412507448-10">
                 <span class="crayon-e">
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10b06412507448-11">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  AND
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  100
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b06412507448-12">
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  t
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10b06412507448-13">
                 <span class="crayon-e">
                  INNER
                 </span>
                 <span class="crayon-e">
                  JOIN
                 </span>
                 <span class="crayon-i">
                  Student
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  s
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  ON
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  t
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0022 seconds] -->
         <p>
         </p>
         <div class="cnblogs_code_toolbar">
         </div>
        </div>
        <p>
         执行时间为：0.001s，这个时间相当靠谱，快了50倍
        </p>
        <p>
         执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281309232553568.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281309253493196.png"/>
         </a>
        </p>
        <p>
         我们会看到，先提取sc，再连表，都用到了索引。
        </p>
        <p>
         那么再来执行下sql
        </p>
        <div class="cnblogs_code">
         <div class="cnblogs_code_toolbar">
         </div>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b0d192875609" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            SELECT s.* from 

Student s

INNER JOIN SC sc

on sc.s_id = s.s_id

where sc.c_id=0 and sc.score=100
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b0d192875609-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b0d192875609-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b0d192875609-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b0d192875609-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b0d192875609-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b0d192875609-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b0d192875609-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b0d192875609-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b0d192875609-9">
                 9
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b0d192875609-1">
                 <span class="crayon-i">
                  SELECT
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-o">
                  *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b0d192875609-2">
                </div>
                <div class="crayon-line" id="crayon-576865dd10b0d192875609-3">
                 <span class="crayon-i">
                  Student
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  s
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b0d192875609-4">
                </div>
                <div class="crayon-line" id="crayon-576865dd10b0d192875609-5">
                 <span class="crayon-e">
                  INNER
                 </span>
                 <span class="crayon-e">
                  JOIN
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-e">
                  sc
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b0d192875609-6">
                </div>
                <div class="crayon-line" id="crayon-576865dd10b0d192875609-7">
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  s_id
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b0d192875609-8">
                </div>
                <div class="crayon-line" id="crayon-576865dd10b0d192875609-9">
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-cn">
                  0
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-cn">
                  100
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0016 seconds] -->
         <p>
         </p>
         <div class="cnblogs_code_toolbar">
         </div>
        </div>
        <p>
         执行时间0.001s
        </p>
        <p>
         执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/281309263808780.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/281309283029693.png"/>
         </a>
        </p>
        <p>
         这里是mysql进行了查询语句优化，先执行了where过滤，再执行连接操作，且都用到了索引。
        </p>
        <p>
        </p>
        <p>
         <span style="color: #008000;">
          最近又重新导入一些生产数据，经测试发现，前几天优化完的sql执行效率又变低了
         </span>
        </p>
        <p>
         <span style="color: #008000;">
          调整内容为SC表的数据增长到300W,学生分数更为离散。
         </span>
        </p>
        <p>
         先回顾下：
        </p>
        <p>
         show index from SC
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/301012440526578.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/301012448024949.png"/>
         </a>
        </p>
        <p>
         执行sql
        </p>
        <div class="cnblogs_code">
         <div class="cnblogs_code_toolbar">
         </div>
         <p>
         </p>
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b13190994782" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            SELECT s.* from 

Student s

INNER JOIN SC sc

on sc.s_id = s.s_id

where sc.c_id=81 and sc.score=84
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b13190994782-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b13190994782-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b13190994782-3">
                 3
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b13190994782-4">
                 4
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b13190994782-5">
                 5
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b13190994782-6">
                 6
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b13190994782-7">
                 7
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b13190994782-8">
                 8
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b13190994782-9">
                 9
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b13190994782-1">
                 <span class="crayon-i">
                  SELECT
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-o">
                  *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b13190994782-2">
                </div>
                <div class="crayon-line" id="crayon-576865dd10b13190994782-3">
                 <span class="crayon-i">
                  Student
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-i">
                  s
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b13190994782-4">
                </div>
                <div class="crayon-line" id="crayon-576865dd10b13190994782-5">
                 <span class="crayon-e">
                  INNER
                 </span>
                 <span class="crayon-e">
                  JOIN
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-e">
                  sc
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b13190994782-6">
                </div>
                <div class="crayon-line" id="crayon-576865dd10b13190994782-7">
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  s_id
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  s
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-e">
                  s_id
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b13190994782-8">
                </div>
                <div class="crayon-line" id="crayon-576865dd10b13190994782-9">
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-cn">
                  81
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  sc
                 </span>
                 <span class="crayon-sy">
                  .
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-cn">
                  84
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0016 seconds] -->
         <p>
         </p>
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b19655808121" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b19655808121-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b19655808121-1">
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <p>
         </p>
         <div class="cnblogs_code_toolbar">
         </div>
        </div>
        <p>
         执行时间：0.061s，这个时间稍微慢了点
        </p>
        <p>
         执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/301012457409561.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/301012467245862.png"/>
         </a>
        </p>
        <p>
         这里用到了intersect并集操作，即两个索引同时检索的结果再求并集，再看字段score和c_id的区分度，
        </p>
        <p>
         单从一个字段看，区分度都不是很大，从SC表检索，c_id=81检索的结果是70001,score=84的结果是39425
        </p>
        <p>
         而c_id=81 and score=84 的结果是897，即这两个字段联合起来的区分度是比较高的，因此建立联合索引查询效率
        </p>
        <p>
         将会更高，从另外一个角度看，该表的数据是300w，以后会更多，就索引存储而言，都是不小的数目，随着数据量的
        </p>
        <p>
         增加，索引就不能全部加载到内存，而是要从磁盘去读取，这样索引的个数越多，读磁盘的开销就越大，因此根据具体
        </p>
        <p>
         业务情况建立多列的联合索引是必要的，那么我们来试试吧。
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b20038124879" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            alter table SC drop index sc_c_id_index;
alter table SC drop index sc_score_index;
create index sc_c_id_score_index on SC(c_id,score);
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b20038124879-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b20038124879-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b20038124879-3">
                 3
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b20038124879-1">
                 <span class="crayon-e">
                  alter
                 </span>
                 <span class="crayon-e">
                  table
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-e">
                  drop
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-v">
                  sc_c_id_index
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b20038124879-2">
                 <span class="crayon-e">
                  alter
                 </span>
                 <span class="crayon-e">
                  table
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-e">
                  drop
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-v">
                  sc_score_index
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10b20038124879-3">
                 <span class="crayon-e">
                  create
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-e">
                  sc_c_id_score_index
                 </span>
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-e">
                  SC
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  c_id
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  score
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0012 seconds] -->
        </div>
        <p>
         <span style="color: #393939; font-family: 微软雅黑;">
          执行上述查询语句，消耗时间为：0.007s，这个速度还是可以接收的
         </span>
        </p>
        <p>
         执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/301012473803261.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/301012480369660.png"/>
         </a>
        </p>
        <p>
         该语句的优化暂时告一段落
        </p>
        <p>
         总结：
        </p>
        <p>
         1.mysql嵌套子查询效率确实比较低
        </p>
        <p>
         2.可以将其优化成连接查询
        </p>
        <p>
         3.连接表时，可以先用where条件对表进行过滤，然后做表连接
        </p>
        <p>
         （虽然mysql会对连表语句做优化）
        </p>
        <p>
         4.建立合适的索引，必要时建立多列联合索引
        </p>
        <p>
         5.学会分析sql执行计划，mysql会对sql进行优化，所以分析执行计划很重要
        </p>
        <h3>
         索引优化
        </h3>
        <p>
         上面讲到子查询的优化，以及如何建立索引，而且在多个字段索引时，分别对字段建立了单个索引
        </p>
        <p>
         后面发现其实建立联合索引效率会更高，尤其是在数据量较大，单个列区分度不高的情况下。
        </p>
        <h3>
         单列索引
        </h3>
        <p>
         查询语句如下：
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b26222900657" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            select * from user_test_copy where sex = 2 and type = 2 and age = 10
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b26222900657-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b26222900657-1">
                 <span class="crayon-e ">
                  select *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  user_test_copy
                 </span>
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sex
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  type
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  age
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  10
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0012 seconds] -->
        </div>
        <p>
         索引：
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b2c214521110" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            CREATE index user_test_index_sex on user_test_copy(sex);
CREATE index user_test_index_type on user_test_copy(type);
CREATE index user_test_index_age on user_test_copy(age);
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b2c214521110-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b2c214521110-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b2c214521110-3">
                 3
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b2c214521110-1">
                 <span class="crayon-e">
                  CREATE
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-e">
                  user_test_index_sex
                 </span>
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-e">
                  user_test_copy
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  sex
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b2c214521110-2">
                 <span class="crayon-e">
                  CREATE
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-e">
                  user_test_index_type
                 </span>
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-e">
                  user_test_copy
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  type
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10b2c214521110-3">
                 <span class="crayon-e">
                  CREATE
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-e">
                  user_test_index_age
                 </span>
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-e">
                  user_test_copy
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  age
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0013 seconds] -->
        </div>
        <p>
         分别对sex,type,age字段做了索引，数据量为300w,查询时间：0.415s
        </p>
        <p>
         执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/291444259742769.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/291444296158422.png"/>
         </a>
        </p>
        <p>
         发现type=index_merge
        </p>
        <p>
         这是mysql对多个单列索引的优化，对结果集采用intersect并集操作
        </p>
        <h3>
         多列索引
        </h3>
        <p>
         我们可以在这3个列上建立多列索引，将表copy一份以便做测试
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b32250552389" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            create index user_test_index_sex_type_age on user_test(sex,type,age);
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b32250552389-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b32250552389-1">
                 <span class="crayon-e">
                  create
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-e">
                  user_test_index_sex_type_age
                 </span>
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-e">
                  user_test
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  sex
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  type
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  age
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                 <span class="crayon-sy">
                  ;
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0008 seconds] -->
        </div>
        <p>
         查询语句：
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b38737204909" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            select * from user_test where sex = 2 and type = 2 and age = 10
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b38737204909-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b38737204909-1">
                 <span class="crayon-e ">
                  select *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  user_test
                 </span>
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sex
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  type
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  age
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  10
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0012 seconds] -->
        </div>
        <p>
         执行时间：0.032s，快了10多倍，且多列索引的区分度越高，提高的速度也越多
        </p>
        <p>
         执行计划：
        </p>
        <p>
         <a href="http://images.cnitblog.com/blog/722277/201504/291444304909521.png">
          <img src="http://dataunion.org/wp-content/uploads/2015/05/291444313185635.png"/>
         </a>
        </p>
        <p>
         <strong>
          最左前缀
         </strong>
        </p>
        <p>
         多列索引还有最左前缀的特性：
        </p>
        <p>
         执行一下语句：
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b3e474211742" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            select * from user_test where sex = 2
select * from user_test where sex = 2 and type = 2
select * from user_test where sex = 2 and age = 10
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b3e474211742-1">
                 1
                </div>
                <div class="crayon-num crayon-striped-num" data-line="crayon-576865dd10b3e474211742-2">
                 2
                </div>
                <div class="crayon-num" data-line="crayon-576865dd10b3e474211742-3">
                 3
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b3e474211742-1">
                 <span class="crayon-e ">
                  select *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  user_test
                 </span>
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sex
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                </div>
                <div class="crayon-line crayon-striped-line" id="crayon-576865dd10b3e474211742-2">
                 <span class="crayon-e ">
                  select *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  user_test
                 </span>
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sex
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  type
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                </div>
                <div class="crayon-line" id="crayon-576865dd10b3e474211742-3">
                 <span class="crayon-e ">
                  select *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  user_test
                 </span>
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sex
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  age
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  10
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0019 seconds] -->
        </div>
        <p>
         都会使用到索引，即索引的第一个字段sex要出现在where条件中
        </p>
        <h3>
         索引覆盖
        </h3>
        <p>
         就是查询的列都建立了索引，这样在获取结果集的时候不用再去磁盘获取其它列的数据，直接返回索引数据即可
        </p>
        <p>
         如：
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b44383021677" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            select sex,type,age from user_test where sex = 2 and type = 2 and age = 10
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b44383021677-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b44383021677-1">
                 <span class="crayon-e">
                  select
                 </span>
                 <span class="crayon-v">
                  sex
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-v">
                  type
                 </span>
                 <span class="crayon-sy">
                  ,
                 </span>
                 <span class="crayon-e">
                  age
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  user_test
                 </span>
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sex
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  type
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  age
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  10
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0013 seconds] -->
        </div>
        <p>
         执行时间：0.003s
        </p>
        <p>
         要比取所有字段快的多
        </p>
        <h3>
         排序
        </h3>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b4a822152165" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            select * from user_test where sex = 2 and type = 2 ORDER BY user_name
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b4a822152165-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b4a822152165-1">
                 <span class="crayon-e ">
                  select *
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  from
                 </span>
                 <span class="crayon-e">
                  user_test
                 </span>
                 <span class="crayon-e">
                  where
                 </span>
                 <span class="crayon-v">
                  sex
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-st">
                  and
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-v">
                  type
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-o">
                  =
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-cn">
                  2
                 </span>
                 <span class="crayon-h">
                 </span>
                 <span class="crayon-e">
                  ORDER
                 </span>
                 <span class="crayon-e">
                  BY
                 </span>
                 <span class="crayon-v">
                  user_name
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0011 seconds] -->
        </div>
        <p>
         时间：0.139s
        </p>
        <p>
         在排序字段上建立索引会提高排序的效率
        </p>
        <div class="cnblogs_code">
         <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
         <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865dd10b4f884542725" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
          <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
           <span class="crayon-title">
           </span>
           <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
            <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-wrap-button" title="切换自动换行">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-expand-button" title="点击展开代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-copy-button" title="复制代码">
             <div class="crayon-button-icon">
             </div>
            </div>
            <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
             <div class="crayon-button-icon">
             </div>
            </div>
           </div>
          </div>
          <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
          </div>
          <div class="crayon-plain-wrap">
           <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
            create index user_name_index on user_test(user_name)
           </textarea>
          </div>
          <div class="crayon-main" style="">
           <table class="crayon-table">
            <tbody>
             <tr class="crayon-row">
              <td class="crayon-nums " data-settings="show">
               <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
                <div class="crayon-num" data-line="crayon-576865dd10b4f884542725-1">
                 1
                </div>
               </div>
              </td>
              <td class="crayon-code">
               <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
                <div class="crayon-line" id="crayon-576865dd10b4f884542725-1">
                 <span class="crayon-e">
                  create
                 </span>
                 <span class="crayon-e">
                  index
                 </span>
                 <span class="crayon-e">
                  user_name_index
                 </span>
                 <span class="crayon-e">
                  on
                 </span>
                 <span class="crayon-e">
                  user_test
                 </span>
                 <span class="crayon-sy">
                  (
                 </span>
                 <span class="crayon-v">
                  user_name
                 </span>
                 <span class="crayon-sy">
                  )
                 </span>
                </div>
               </div>
              </td>
             </tr>
            </tbody>
           </table>
          </div>
         </div>
         <!-- [Format Time: 0.0006 seconds] -->
        </div>
        <p>
        </p>
        <p>
         最后附上一些sql调优的总结，以后有时间再深入研究
        </p>
        <p>
         1. 列类型尽量定义成数值类型，且长度尽可能短，如主键和外键，类型字段等等
        </p>
        <p>
         2. 建立单列索引
        </p>
        <p>
         3. 根据需要建立多列联合索引
        </p>
        <p>
         当单个列过滤之后还有很多数据，那么索引的效率将会比较低，即列的区分度较低，
        </p>
        <p>
         那么如果在多个列上建立索引，那么多个列的区分度就大多了，将会有显著的效率提高。
        </p>
        <p>
         4. 根据业务场景建立覆盖索引
        </p>
        <p>
         只查询业务需要的字段，如果这些字段被索引覆盖，将极大的提高查询效率
        </p>
        <p>
         5. 多表连接的字段上需要建立索引
        </p>
        <p>
         这样可以极大的提高表连接的效率
        </p>
        <p>
         6. where条件字段上需要建立索引
        </p>
        <p>
         7. 排序字段上需要建立索引
        </p>
        <p>
         8. 分组字段上需要建立索引
        </p>
        <p>
         9. Where条件上不要使用运算函数，以免索引失效
        </p>
        <p>
        </p>
        <p>
         <strong>
          参考文章
         </strong>
        </p>
        <p>
         <a href="http://www.cnblogs.com/linfangshuhellowored/p/4430293.html">
          http://www.cnblogs.com/linfangshuhellowored/p/4430293.html
         </a>
        </p>
        <p>
         慢sql查询
        </p>
        <p>
         <a href="http://tech.meituan.com/mysql-index.html">
          http://tech.meituan.com/mysql-index.html
         </a>
        </p>
        <p>
         笛卡尔乘积
        </p>
        <p>
         <a href="http://www.cnblogs.com/Toolo/p/3634563.html">
          http://www.cnblogs.com/Toolo/p/3634563.html
         </a>
        </p>
        <p>
         sql优化
        </p>
        <p>
         <a href="http://www.cnblogs.com/mliang/p/3637937.html">
          http://www.cnblogs.com/mliang/p/3637937.html
         </a>
        </p>
        <p>
         <a href="http://www.cnblogs.com/xwdreamer/archive/2012/07/19/2599494.html">
          http://www.cnblogs.com/xwdreamer/archive/2012/07/19/2599494.html
         </a>
        </p>
        <p>
         执行计划参考：
        </p>
        <p>
         <a href="http://www.cnblogs.com/ggjucheng/archive/2012/11/11/2765237.html">
          http://www.cnblogs.com/ggjucheng/archive/2012/11/11/2765237.html
         </a>
        </p>
       </div>
       <div id="MySignature">
        <blockquote>
         <div>
          作者：
          <a href="http://www.cnblogs.com/tangyanbo/" target="_blank">
           风过无痕-唐
          </a>
          <br/>
          出处：
          <a href="http://www.cnblogs.com/tangyanbo/" target="_blank">
           http://www.cnblogs.com/tangyanbo/
          </a>
         </div>
        </blockquote>
       </div>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/24670.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/20141222134630106-300x164.png"/>
        </a>
        <a class="link" href="http://dataunion.org/24670.html" rel="bookmark" title="Apache Spark 不过时的六大理由">
         Apache Spark 不过时的六大理由
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24558.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/wKiom1dcvqDBYzojAAF3j3hfL_s877.jpg-wh_651x-s_1673119543-300x197.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24558.html" rel="bookmark" title="实现R与Hadoop联合作业的三种方法">
         实现R与Hadoop联合作业的三种方法
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24454.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/234040u557x77z325w2g3o-267x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24454.html" rel="bookmark" title="LinkedIn 开源其分布式对象存储系统 Ambry">
         LinkedIn 开源其分布式对象存储系统 Ambry
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24349.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/05/20150402110749389-249x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24349.html" rel="bookmark" title="生活处处皆学问，我从星巴克咖啡学到的5点架构经验">
         生活处处皆学问，我从星巴克咖啡学到的5点架构经验
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F16381.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/16381.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/16381.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>